package com.my.screenadapter.mTextview;

import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

import com.my.screenadapter.Base.BaseActivity;
import com.my.screenadapter.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * @author zyj 2019-09-03
 * @function 字体更改
 */
public class TTFActivity extends BaseActivity {


    @BindView(R.id.tv_origin)
    TextView tvOrigin;
    @BindView(R.id.tv_origin_change)
    TextView tvOriginChange;
    @BindView(R.id.tv_origin_bold)
    TextView tvOriginBold;
    @BindView(R.id.tv_origin_change_bold)
    TextView tvOriginChangeBold;

    //todo background null point 预防
    //mtvPrintState.getBackground().setAlpha((int) (255 * 0.6));//0~255透明度值


    //tv.setBackgroundColor(Color.argb(255, 0, 255, 0)); //背景透明度
    //tv.setTextColor(Color.argb(255, 0, 255, 0));   //文字透明度

    //第2种方法：
    //tv.setTextColor(0xffff00ff);
    //0xffff00ff是int类型的数据，分组一下0x|ff|ff00ff，0x是代表颜色整数的标记，ff是表示透明度，ff00ff表示颜色，
    //注意：这里ffff00ff必须是8个的颜色表示，不接受ff00ff这种6个的颜色表示



    @Override
    protected void init() {
        Typeface typeface = Typeface.createFromAsset(getAssets(), "fontSimple.ttf");
        StringBuilder sb = new StringBuilder();


        for (int i = 0; i < 26; i++) {
            sb.append((char) ('a'+i));//提升为int，计算结果98对应的字符是b。
            sb.append(" ");
        }

        for (int i = 0; i < 26; i++) {
            sb.append((char)('A'+i));
            sb.append(" ");
        }
        sb.append("\n Vistor Name Unit time Receptionist \n 访客姓名，单位，时间，");
        tvOriginChange.setTypeface(typeface);
        tvOriginChangeBold.setTypeface(typeface);

        tvOrigin.setText(sb.toString());
        tvOriginBold.setText(sb.toString());
        tvOriginChange.setText(sb.toString());
        tvOriginChangeBold.setText(sb.toString());


    }

    @Override
    protected int initLayoutId() {
        return R.layout.activity_ttf;
    }

}
